#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<stack>
#define PI acos(-1)
#define MP make_pair
#define PB push_back
#define VI vector <int>
#define PII pair <int,int>
#define LL long long
#define SET(v,i) memset(v, i, sizeof(v))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define FORN(i,a,b) for (int i = (a); i < (b); i++)
#define DOWN(i,a,b) for (int i = (a); i > (b); i--)
#define FIT(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); it++)
#define FITD(it,v) for (typeof(v.rbegin()) it = v.rbegin(); it != v.rend(); it++)
using namespace std;
const int N=200050;
char a[N],b[N];
double dp[2][256];
int main(){
	int n;
	while(scanf("%d%s%s",&n,a,b)!=EOF){
		for(int i=0;i<256;i++)dp[0][i]=dp[1][i]=0;
		double ans=0;
		for(int i=0;i<n;i++){
			dp[0][b[i]]+=i+1;
			ans+=(n-i)*(dp[0][a[i]]+dp[1][b[i]]);
			dp[1][a[i]]+=i+1; 
			} 
		printf("%lf\n",6*ans/n/(n+1)/(2*n+1));
		}
    return 0;
    }
